package lcci;

import java.util.HashSet;
import java.util.Set;

public class leetcode0104 {
    public static void main(String[] args) {
        System.out.println(canPermutePalindrome("tactcoa"));
    }

    public static boolean canPermutePalindrome(String s) {
        if (s == null) {
            return false;
        }
        char[] chars = s.toCharArray();
        Set<Character> count = new HashSet<>();
        for (char c : chars) {
            if (count.contains(c)) {
                count.remove(c);
            } else {
                count.add(c);
            }
        }
        return count.size() <= 1;
    }
}
